package com.lw.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;


/**
 * 操作日志 表定义层。
 *
 * @author lw
 * @since 2025年04月30日 16:10:43
 */
public class TbOperationLogTableDef extends TableDef {

    private static final long serialVersionUID = 1L;

    /**
     * 操作日志
     */
    public static final TbOperationLogTableDef TB_OPERATION_LOG = new TbOperationLogTableDef();

    /**
     * id
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 操作IP
     */
    public final QueryColumn IP = new QueryColumn(this, "ip");

    /**
     * 状态  0：失败   1：成功
     */
    public final QueryColumn STATUS = new QueryColumn(this, "status");

    /**
     * 创建者
     */
    public final QueryColumn CREATOR = new QueryColumn(this, "creator");

    /**
     * 用户操作
     */
    public final QueryColumn OPERATION = new QueryColumn(this, "operation");

    /**
     * 用户代理
     */
    public final QueryColumn USER_AGENT = new QueryColumn(this, "user_agent");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_DATE = new QueryColumn(this, "create_date");

    /**
     * 请求URI
     */
    public final QueryColumn REQUEST_URI = new QueryColumn(this, "request_uri");

    /**
     * 用户名
     */
    public final QueryColumn CREATOR_NAME = new QueryColumn(this, "creator_name");

    /**
     * 请求时长(毫秒)
     */
    public final QueryColumn REQUEST_TIME = new QueryColumn(this, "request_time");

    /**
     * 请求方式
     */
    public final QueryColumn REQUEST_METHOD = new QueryColumn(this, "request_method");

    /**
     * 请求参数
     */
    public final QueryColumn REQUEST_PARAMS = new QueryColumn(this, "request_params");
    public final QueryColumn OBJ_ID = new QueryColumn(this, "obj_id");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, OPERATION, REQUEST_URI, REQUEST_METHOD, REQUEST_PARAMS, REQUEST_TIME, USER_AGENT, IP, STATUS, CREATOR_NAME, CREATOR, CREATE_DATE,OBJ_ID};

    public TbOperationLogTableDef() {
        super("", "tb_operation_log");
    }

    private TbOperationLogTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public TbOperationLogTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new TbOperationLogTableDef("", "tb_operation_log", alias));
    }

}
